<?php
require_once '../../../config/koneksi.php';
require_once '../../../config/class_paging_param.php';
?>
<link href="../../../asset/css/admin_style.css" type="text/css" rel="stylesheet">
<link href="../../../asset/css/paging.css" type="text/css" rel="stylesheet">

<script type="text/javascript">
function setParent(id_jaminan, no_jaminan,nama,tahun) {
	window.opener.document.getElementById('id_jaminan').value = id_jaminan;
	window.opener.document.getElementById('no_peserta').value = no_jaminan;
	window.opener.document.getElementById('nama_peserta').value = nama;
	window.opener.isi_umur(tahun);
	self.close();
}
</script>
<?php
	if(!empty($_GET['nama'])){
		$param_nama=$_GET['nama'];
	}else{
		$param_nama=$_POST['nama'];
	}
?>
<form method=post action="">
	<table style="margin-left: 5px;" width="780" >
		<tr>
			<td width="65">Pencarian  : </td>
			<td width="200"><input type="text" name="nama" value="<?php echo $param_nama; ?>" class="input_field" /></td>
			<td><input name="submit" type="submit" class="button" value="Cari" /></td>
		</tr>
	</table>
</form>
<table class="tabel2">
	<tr>
		<th>NO</th>
		<th>No Jaminan </th>
		<th>Nama Penduduk </th>
		<th>Aksi</th>
	</tr>
<?php
$p= new paging ;
		$batas= 10;
		$id_ppk=$_GET['id_ppk'];
		//cek halaman dan posisi halaman
		$posisi = $p ->cariposisi($batas) ;
		$sql="select id_jaminan, p.id_peserta, nama, tempat_lahir, tgl_lahir, jenis_peserta, tgl_selesai, year(tgl_lahir) as tahun_lahir,id_jaminan_sebelumnya from jaminan ja inner join peserta p on ja.id_peserta = p.id_peserta inner join penduduk pn on p.id_penduduk = pn.id_penduduk inner join jenis_peserta j on p.id_jenis_peserta = j.id_jenis_peserta where p.id_peserta like '%$param_nama%' order by p.id_peserta desc limit $posisi,$batas";
		//echo $sql;
		$qry=mysql_query($sql);
		$no=$posisi + 1;
//$sql="select * from master_diagnosis";
//$qry=mysql_query($sql);
//$no=1;
while($hasil=mysql_fetch_array($qry)){
?>
	<tr>
		<td align="center" width="30"><?php echo $no;?></td>
		<td ><?php echo $hasil['id_jaminan'];?></td>
		<td align="left" width="60"><?php echo $hasil['nama'];?></td>
		<td align="center" width="60">
		<a href="javascript:setParent('<?php echo $hasil['id_jaminan']?>','<?php echo $hasil['id_peserta']?>','<?php echo $hasil['nama']?>','<?php echo $hasil['tahun_lahir']?>')" onclick=""><img src="../../../asset/images/button-check.gif"></a>				</td>
	</tr>
<?php
$no++;
}
?>
</table>
<?php
	$sql2="select * from keluarga k inner join desa d on k.id_desa = d.id_desa inner join kecamatan kc on d.id_kecamatan = kc.id_kecamatan inner join kabupaten kb on kc.id_kabupaten = kb.id_kabupaten inner join propinsi p on kb.id_propinsi = p.id_propinsi where id_kk like '%$param_nama%'" ;
	$query2=mysql_query($sql2);
	$jumlah_data=mysql_num_rows($query2);
	//dapatkan jumlah halaman
	$jumlah_halaman= $p->jumlahhalaman($jumlah_data,$batas);
	//cetak link
	$linkhalaman=$p->navhalaman($_GET['halaman'],$jumlah_halaman,$_SERVER['PHP_SELF']."?","nama=$param_nama");
	print($linkhalaman);
?>